package com.pactera.madp.cp.controller.oms.remind;

import com.pactera.madp.common.core.util.R;
import com.pactera.madp.common.log.annotation.SysLog;
import com.pactera.madp.cp.api.dto.clientLossManagement.*;
import com.pactera.madp.cp.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @date: 2021/7/26 15:57
 * @description:
 */
@RestController
@AllArgsConstructor
@RequestMapping("/clientlossmanage")
@Api(value = "clientlossmanage", tags = "客户流失管理-提醒设置")
public class RemindController {

    @Resource
    private RemindDeleteService remindDeleteService;
    @Resource
    private RemindCommunicationService remindCommunicationService;
    @Resource
    IWorkContactTagGroupService workContactTagGroupService;

    /**
     * 开启/关闭开关
     *
     * @param status
     * @return
     */
    @SysLog("客户流失管理-提醒设置-开启/关闭")
    @PutMapping("/select/{status}")
    @ApiOperation(value = "开启/关闭")
    public R selectSwitch(@PathVariable Integer status){
        return remindDeleteService.selectSwitch(status);
    }

    @GetMapping("/querystatus")
    @ApiOperation(value = "查询状态")
    public R getStatus(){return remindDeleteService.queryStatus();}

    @GetMapping("/gettag")
    @ApiOperation(value = "获取全部标签列表")
    public R getAllTag(){return remindCommunicationService.getAllTag();}

    @GetMapping("/query")
    @ApiOperation(value = "查询记录")
    public R getRecord(){return remindCommunicationService.queryRecord();}

    @SysLog("客户流失管理-提醒设置-新增规则")
    @PostMapping
    @ApiOperation(value = "新增规则")
    public R addRule (@RequestBody RemindCommunicationAddDTO remindCommunicationAddDTO) {return remindCommunicationService.setRule(remindCommunicationAddDTO);}

    @SysLog("客户流失管理-提醒设置-修改规则")
    @PutMapping("/update-rule")
    @ApiOperation(value = "修改规则")
    public R updateRule(@RequestBody RemindCommunicationUpdateDTO remindCommunicationUpdateDTO) {return remindCommunicationService.updateRule(remindCommunicationUpdateDTO);}

    @SysLog("客户流失管理-提醒设置-删除规则")
    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除规则")
    public R deleteRule(@PathVariable Integer id) {
        return remindCommunicationService.deleteRule(id);
    }

}
